/**
 * @param {state,action} 接受两个参数
 * @return 返回最新的参数
 */
const initState = {
  count: 0,
}
export const reducer = (state = initState, action) => {
  switch (action.type) {
    case 'add_action':
      return {
        count: state.count + 1,
      }
    case 'sub_action':
      return {
        count: state.count > 0 ? state.count - 1 : 0,
      }
    default:
      return state
  }
}
